//
//  ProfileDetailViewController.m
//  Gradekeeper0.2
//
//  Created by Lily Wang on 11/2/09.
//  Copyright 2009 i5. All rights reserved.
//

#import "ProfileDetailViewController.h"
#import "changePastInfo.h"
#import "Profile.h"



@implementation ProfileDetailViewController

@synthesize cinfo, editbutton, userInputGPA, userInputSemester, userInputCredits;



- (void)editAction:(id)sender{
	if (self.cinfo == nil){
		ChangePastInfo * c= [[ChangePastInfo alloc] initWithNibName:@"ChangePastInfo" bundle:nil];
		self.cinfo = c;
		[c release];
	}
	
	[self.navigationController pushViewController:cinfo animated:YES];
} //createPressed


- (void)viewDidLoad {
    [super viewDidLoad];
	
	
	UIBarButtonItem *editButton = [[UIBarButtonItem alloc] initWithTitle:@"Edit" 
																	 style:UIBarButtonItemStyleBordered 
																	target:self 
																	action:@selector(editAction:)]; 
	self.navigationItem.rightBarButtonItem = editButton; 
	[editButton release]; 
	
	// create a custom navigation bar button and set it to say "back"
	UIBarButtonItem *temporaryBarButtonItem = [[UIBarButtonItem alloc] init];
	temporaryBarButtonItem.title = @"Back";
	self.navigationItem.backBarButtonItem = temporaryBarButtonItem;
	[temporaryBarButtonItem release];
}

- (void)viewDidUnload
{
   
    self.editbutton = nil;
}


-(void)viewWillAppear:(BOOL)animated {
	NSLog(@"view will appear");
   Profile *profile = [Profile sharedProfile];
	
	userInputGPA.text = [profile getCGPA];
	
	userInputCredits.text = [profile getCreditsUsed];
	userInputSemester.text = [profile getSemester];

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview
    // Release anything that's not essential, such as cached data
}


- (void)dealloc {
	[userInputGPA release];
	[userInputSemester release];
	[userInputCredits release];
    [super dealloc];
}


@end

